public class Solution1894 {
    public int chalkReplacer(int[] chalk, int k) {
        long total=0;
        for (int i : chalk) {
            total=total+i;
        }
        k%=total;
        for (int i=0;i<chalk.length;i++){
            k=k-chalk[i];
            if (k<0){
                return i;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1894().chalkReplacer(new int[]{3,4,1,2},25));
    }
}
